<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>表单组合</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="__PUBLIC__/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">积分调整</div>
        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" action="javascript:;" lay-filter="component-form-group" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">变动账户</label>
                    <div class="layui-input-block">
                        <input type="text" id="title" lay-verify="title" autocomplete="off" placeholder="请输入用户手机号" onblur="Upoints()" class="layui-input">
                        <p style="color: red" id="ponit"></p>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">方式</label>
                        <div class="layui-input-inline">
                            <select id="type">
                                <option value="1">增加</option>
                                <option value="0">减少</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-input-block">
                        <input type="number" id="points" lay-verify="title" autocomplete="off" placeholder="请输入变动金额" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <textarea id="desc" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;">
                            <button class="layui-btn" lay-filter="component-form-demo1" onclick="sub()">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>


<script src="__PUBLIC__/layuiadmin/layui/layui.js"></script>
<script>
    layui.use(['form', 'layer'], function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;
    });
    //提交变动信息
    function sub() {
        var points = $("#points").val();
        var type = $("#type").val();
        var desc = $("#desc").val();
        var phone = $("#title").val();
        $.ajax({
            type:'post',
            url:'{:url("User/userPoints")}',
            data:{desc:desc,type:type,points:points,phone:phone},
            success: function (data) {
                if(data.code>0){
                    layer.msg(data.msg,{icon:1,time:1500});
                    setTimeout(function(){parent.location.reload()},1500);
                }else{
                    layer.msg(data.msg,{icon:5,time:1500});
                }
            },
        });
    }
    //检测变动账户
    function Upoints() {
        var phone = $("#title").val();
        if(phone == ''){
            layer.msg('请先填写账户信息');
            return false;
        }
        $.ajax({
            type:'post',
            url:'{:url("User/pointsFind")}',
            data:{phone:phone},
            success: function (data) {
                if(data.code > 0){
                    $("#ponit").html('账户积分:'+data.msg);
                }else{
                    layer.msg(data.msg, {icon: 5 ,time : 1000});
                }
            }
        });
    }
</script>
</body>
</html>
